2020.02.03-2020.02.09
这周学得比较少 因为刚把输入法从全拼换成双拼 在练习打字…
1.搞博客
- 在博客里加入了点效果(小声bb:以前觉得应该挺复杂的,其实有了轮子之后也就一行代码的事啊)
参考:https://github.com/VincentGarreau/particles.js - 了解了GitHub上博客的结构
使用 GitHub, Jekyll 打造自己的免费独立博客
2.汇编语言学习
div指令
- div是除法指令
- 除数:有8位和16位两种,在一个寄存器或内存单元中
- 被除数:默认放在ax或dx和ax中
如果除数为8位,则被除数为16位,默认放在ax中存放
如果除数为16位,则被除数位32位,在dx和ax中存放,dx存放高16位,ax存放低16位 - 结果:
除数为8位(16^2-1=255),al储存商,ah储存余数
除数为16位(16^4-1=65535),ax储存商,dx储存余数
-
div byte ptr ds:[0]含义:
-
(al)=(ax)/((ds)*16+0)的商
(ah)=(ax)/((ds)*16+0)的余数
div word ptr [bx+si+8]含义:
-
(ax)=[(dx)*10000h+(ax)]/((ds)*16+(bx)+(si)+8)的商
(dx)=[(dx)*10000h+(ax)]/((ds)*16+(bx)+(si)+8)的余数
dd指令
- 用db定义字节型数据
- 用dw定义字型数据
- 用dd定义double(双字)型数据
dup
dup是一个操作符,和db、dw、dd等数据定义伪指令配合使用,用来进行数据的重复
db/dw/dd 重复次数 dup(重复的数据)
-
如:
-
db 200 dup (0)
:定义了200个字节的0
db 3 dup (‘abc’)
:定义了9个字节:‘abcabcabc’
转移指令
指可以修改ip或同时修改cs和ip的指令
-
段内转移:只修改ip
短转移:-128~127
近转移:-32768~32767 -
段间转移:同时修改cs和ip
3.c语言-学生成绩管理系统
#include<stdio.h>
#include<stdlib.h>
struct stu {
int num;
char name[10];
int sex;
int age;
int score;
struct stu* next;
};
struct stu *p;
void menu() {
printf("chose a function:\n"
"1.录入信息\n"
"2.打印信息\n"
"3.保存信息\n"
"4.读取信息\n"
"5.统计所有人数\n"
"6.按学号查找信息\n"
"7.修改信息\n"
"8.删除信息\n"
"9.退出\n");
}
void remove();
void build();
void print(struct stu *p);
void sum(struct stu *p);
void save(struct stu *p);
void find(struct stu *p);
void modify(struct stu *p);
void read();
int main() {
int n;
while(1) {
menu();
scanf("%d",&n);
switch(n) {
case 9:
return 0;
case 1://录入
build();
break;
case 2://打印
print(p);
break;
case 3://保存
save(p);
break;
case 4://读取
read();
break;
case 5://统计人数
sum(p);
break;
case 6://查找
find(p);
break;
case 7://修改
modify(p);
break;
case 8://删除
remove();
break;
default:
printf("Wrong num\n");
continue;
}
}
}
//
void build() {
struct stu *head=NULL,*nextp;
if(p!=NULL) {
head=p;
while(head->next!=NULL) {
head=head->next;
}
}
printf("顺序输入学号 姓名 性别(男1女0)年龄 成绩 输入-1结束\n");
nextp=(struct stu*)malloc(sizeof(struct stu));
nextp->next=NULL;
scanf("%d",&nextp->num);
while(nextp->num!=-1) {
scanf("%s %d %d %d",nextp->name,&nextp->sex,&nextp->age,&nextp->score);
if(head==NULL) {
p=nextp;
head=p;
} else {
head->next=nextp;
head=head->next;
}
nextp=(struct stu*)malloc(sizeof(struct stu));
nextp->next=NULL;
scanf("%d",&nextp->num);
}
}
//
void print(struct stu *p) {
while(p) {
printf("%d %s %d %d %d\n",p->num,p->name,p->sex,p->age,p->score);
p=p->next;
}
}
//
void sum(struct stu *p) {
int i=0;
while(p) {
p=p->next;
i++;
}
printf("%d\n",i);
}
//
void find(struct stu *p) {
printf("输入学号: ");
int num;
scanf("%d",&num);
while(1) {
if(p->num==num) {
break;
}
p=p->next;
if(p==NULL)
break;
}
if(p!=NULL)
printf("%d %s %d %d %d\n",p->num,p->name,p->sex,p->age,p->score);
else
printf("Wrong Number\n");
}
void modify(struct stu *p) {
struct stu *head;
head=p;
int num;
printf("输入修改学生的学号:\n");
scanf("%d",&num);
while(head) {
if(head->num!=num) {
head=head->next;
} else
break;
}
if(p==NULL)
printf("学号错误");
else {
printf("输入修改学生的信息:\n");
printf("顺序输入姓名 性别(男1女0)年龄 成绩 输入:\n");
scanf("%s %d %d %d",head->name,&head->sex,&head->age,&head->score);
printf("成功修改\n");
print(p);
}
}
void remove() {
printf("输入删除的学生学号: ");
int n;
scanf("%d",&n);
struct stu *head,*nextp,*d;
head=p;
nextp=(struct stu *)malloc(sizeof(struct stu));
d=(struct stu *)malloc(sizeof(struct stu));
if(head->num==n) {
p=p->next;
free(head);
} else {
while(head) {
if(n!=head->num){
head=head->next;
nextp->next=head;
}
else
break;
}
if(head==NULL)
printf("学号错误");
else {
d=head;
head=head->next;
free(d);
nextp->next=head;
printf("success");
}
}
}
void save(struct stu *p) {
FILE* fp;
fp = fopen(".\\stuinfo.txt", "w");
while (p) {
fprintf(fp,"%d %s %d %d %d\n",p->num,p->name,p->sex,p->age,p->score);
p = p->next;
}
fclose(fp);
printf("数据保存成功。\n");
}
void read(){
if(p!=NULL){
struct stu *nextp=p->next;
free(p);
while(nextp){
p=nextp;
nextp=nextp->next;
free(p);
}
}
FILE *fp;
fp=fopen(".\\stuinfo.txt","r");
if(fp==NULL){
printf("文件无法打开");
}else{
struct stu *nextp,*head;
head=NULL;
nextp=(struct stu*)malloc(sizeof(struct stu));
nextp->next=NULL;
while(fscanf(fp,"%d",&nextp->num)==1){
fscanf(fp,"%s",nextp->name);
fscanf(fp,"%d",&nextp->sex);
fscanf(fp,"%d",&nextp->age);
fscanf(fp,"%d",&nextp->score);
if(head==NULL){
head=nextp;
p=head;
}
else{
head->next=nextp;
head=head->next;
}
nextp=(struct stu*)malloc(sizeof(struct stu));
nextp->next=NULL;
}
fclose(fp);
}
}