16 bit çarpım ve 32 bit sonuç için şöyle bir ASM örnek verilmiş.
https://developer.arm.com/documentation/ka002453/latest
Temel bilgi eksikliğim var ASM kod ?PR? kısmı sanki yazım hatası gibi. aynen yazdım olmadı
NAME MULT
?PR?_uint_mult?MULT SEGMENT CODE
PUBLIC _uint_mult
RSEG ?PR?_uint_mult?MULT
_uint_mult:
; x stored in R6+R7
; y stored in R4+R5
mov a,r7
mov b,r5
mul ab ; ab = R7*R5
mov r3,b
xch a,r7 ; a = R7
mov b,r4
mul ab ; ab = R4*R7
add a,r3
mov r3,a
mov a,#0
addc a,b
xch a,r5 ; a = R5
mov b,r6
mul ab ; ab = R5*R6
add a,r3
xch a,r6
xch a,b ; b = R6
addc a,r5
mov r5,a
mov a,#0
addc a,#0
xch a,r4
mul ab ; ab = R4*R6
add a,r5
mov r5,a
mov a,b
addc a,r4
mov r4,a
; Result returned in R4+R5+R6+R7
RET
END
Bu örneği C kod içine dahil ederek kullanmak istiyorum. Nasıl yazacağımı kestiremedim
Şunun içerisine nasıl ekleyebilirim?
C:\Keil_v5\C51\Examples\HELLO
/*------------------------------------------------------------------------------
HELLO.C
Copyright 1995-2005 Keil Software, Inc.
------------------------------------------------------------------------------*/
#include <REG52.H> /* special function register declarations */
/* for the intended 8051 derivative */
#include <stdio.h> /* prototype declarations for I/O functions */
#ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* Stop Exection with Serial Intr. */
/* is enabled */
/*------------------------------------------------
The main C function. Program execution starts
here after stack initialization.
------------------------------------------------*/
void main (void) {
/*------------------------------------------------
Setup the serial port for 1200 baud at 16MHz.
------------------------------------------------*/
#ifndef MONITOR51
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 221; /* TH1: reload value for 1200 baud @ 16MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
#endif
/*------------------------------------------------
Note that an embedded program never exits (because
there is no operating system to return to). It
must loop and execute forever.
------------------------------------------------*/
while (1) {
P1 ^= 0x01; /* Toggle P1.0 each time we print */
printf ("Hello World\n"); /* Print "Hello World" */
}
}
You must prototype this routine in your C code as follows:
unsigned long uint_mult (
unsigned int x,
unsigned int y);
main?
unsigned long z;
unsigned int x, y;
unsigned long z1;
for (x = 0; x < 0xFF00; x += 13)
{
for (y = 0; y < 0xFF00; y += 17)
{
z1 = (unsigned long) x * y;
z = uint_mult (x, y);
if (z != z1)
{
printf ("0x%4.4X x 0x%4.4X = ", x, y);
printf ("0x%8.8LX (0x%8.8LX)\n", z, z1);
}
}
}
16 bit iki sayıyı çarparak sonucu gösteren program hazır fakat çalıştıramadım
Güncel